package com.fishing.listener;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import com.alibaba.druid.support.logging.Log;
import com.alibaba.druid.support.logging.LogFactory;

public class SessionListener implements HttpSessionListener{

	private Log log = LogFactory.getLog(SessionListener.class);
	
	/**
	 * 创建session时候的动作
	 * @param event
	 * */
	@Override
	public void sessionCreated(HttpSessionEvent event) {
	 
	}
	
	/**
	 * 销毁session时候的动作
	 * @param event
	 * */
	public void sessionDestroyed(HttpSessionEvent event) {
		HttpSession session = event.getSession();
		String sessionId = session.getId();
		//移除loginUsers中已经被销毁的session
		LoginUserMap.removeUser(sessionId);
		log.info(sessionId + "被销毁!");
	}
	
}
